package com.sk.bilibili.model.fragment.search;

import com.sk.api.annotations.Autowired;
import com.sk.bilibili.bean.Live;
import com.sk.bilibili.callBack.RequestCallBack;
import com.sk.bilibili.dto.Page;
import com.sk.bilibili.mapper.SearchMapper;
import com.sk.bilibili.other.JsonMap;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.view.fragment.search.BaseSearchFragment;
import com.sk.bilibili.view.fragment.search.LiveFragment;

public class LiveModel extends BaseSearchModel<LiveFragment>{

    @Autowired
    SearchMapper searchMapper;

    @Override
    public void loadData() {
        JsonMap map = getJsonMap();
        RequestUtils.process(searchMapper.searchLive(map), livePage -> {
            view.addData(livePage.getRecords());
            page++;
        });
    }

    @Override
    public void refreshData() {
        page=1;
        JsonMap map = getJsonMap();
        RequestUtils.process(searchMapper.searchLive(map), livePage -> {
            view.setData(livePage.getRecords());
            view.setNum(livePage.getTotal());
            page++;
        });
    }

}